﻿namespace Bootsy.PEG

callable Action()

/*
TODO: consider a different approach
where the parser exposes BeginTransaction() instead of
IMarkResetEnumerator.

The parser would then also expose a OnAction which
would execute an Action immediately if not inside a 
transaction and simply add it to the current transaction
otherwise. The same for OnError.

interface IParser:
	Context:
		get
	Input as IEnumerator of char:
		get
	def BeginTransaction() as IParserTransaction
	def OnAction(action as Action)
	def OnError(action as ErrorAction)
	
A grammar rule would then be simply:
	
interface IGrammarRule:
	def Apply(parser as IParser) as bool
*/

interface IParser:
	Context:
	"""
	Application dependent context information.
	"""
		get
		
	Input as IMarkResetEnumerator:
		get
		
	def Evaluate(rule as IGrammarRule) as Action
	
interface IGrammarRule:
	def Apply(parser as IParser) as Action
	"""
	Parses the input and in the case of a match
	returns an Action which will be invoked when
	the complete parsing operation is considered
	successful.
	
	Parse should behave as a pure function, in other
	words, for the same input it should yield the
	exact same action.
	"""
